#!/usr/bin/env python
# -*- coding: utf8 -*-

'''
Created on 2011-8-2

@author: zhongfeng
'''

from pageparser import ObuyUrlSummary
from spider import ObuySpider
from amazon.amazonpageparser import AmazonSort3JsonParser, AmazonSort1Parser,\
    AmazonSort2PageParser
from amazon.amazonpageparser import AmazonAllSortParser

if __name__ == '__main__':

    parserDict = {0:AmazonAllSortParser,1:AmazonSort1Parser,2:AmazonSort2PageParser,3:AmazonSort3JsonParser}
    
    rootObuyUrlSummary = ObuyUrlSummary(url=r'http://www.amazon.cn/',parentPath=[], catagoryLevel=0)
    
    sort1 = ObuyUrlSummary(url = ur'http://www.amazon.cn/s/ref=nb_sb_noss?__mk_zh_CN=%E4%BA%9A%E9%A9%AC%E9%80%8A%E7%BD%91%E7%AB%99&url=search-alias%3Dappliances&field-keywords=&x=17&y=11',name='amazon',  
                                 parentPath=[rootObuyUrlSummary],isRecursed = True,catagoryLevel = 1)
    
    sort2 = ObuyUrlSummary(url = ur'http://www.amazon.cn/gp/search/ref=sr_nr_n_0?rh=n%3A80207071%2Cn%3A!80208071%2Cn%3A81948071&bbn=80208071&ie=UTF8&qid=1313135682&rnid=80208071',name='amazon',  
                                 parentPath=[rootObuyUrlSummary,sort1],isRecursed = True,catagoryLevel = 2)
    
    spider = ObuySpider(rootUrlSummary = rootObuyUrlSummary,parserDict = parserDict,include =None,exclude = None,threadNum = 5)
    spider.spide()
    